package javase.module2.task05;

public class StaticOuter {
    private int cnt = 1;
    private static int snt = 2;

    public /*static*/ void show() {
        System.out.println("外部类的show方法！");
    }

    // 定义静态内部类，有static关键字修饰隶属于类层级，不能访问非静态的成员
    public static class StaticInner {
        private int ia = 3;
        private static int snt = 4;

        public StaticInner() {
            System.out.println("静态内部类构造方法");
        }

        public void show() {
            System.out.println("ia = "+ ia);
            System.out.println("外部类中的snt = "+ snt);
            // System.out.println("外部类的cnt ="+ cnt);   // 静态类不能访问非静态成员
        }

        public void show2(int snt) {
            System.out.println("snt = "+ snt);
            System.out.println("内部类 snt = "+ StaticInner.snt);  // 4
            System.out.println("外部类 snt = "+ StaticOuter.snt);  // 2
            //StaticOuter.show();
            new StaticOuter().show();
        }
    }
}
